package gld.algo.park;

import gld.infra.*;

import java.util.*;

public class Stage {
	
	private final HashSet<Drivelane> enabledLanes;
	private final HashMap<Drivelane, Boolean> laneLights;
	
	/**
	 * 
	 * @param lanes Lanes that can be turned green in a stage
	 * @param i
	 * @throws InfraException
	 */
	public Stage(HashSet<Drivelane> lanes, Intersection i) throws InfraException {
		enabledLanes = lanes;
		laneLights = new HashMap<Drivelane, Boolean>();
		for (Drivelane lane : i.getJunction().getInboundLanes()) {
			if (lanes.contains(lane)) 
				laneLights.put(lane, true);
			else
				laneLights.put(lane, false);
		}
	
	}

	public HashSet<Drivelane> getEnabledDrivelanes() {
		return enabledLanes;
	}
	
	public HashMap<Drivelane, Boolean> getDrivelaneLights() {
		return laneLights;
	}
	
	public String toString() {
		String s = "";
		for (Drivelane lane : enabledLanes) 
			s += lane + " ";
		return s;
	}
}
